import React ,{useEffect, useState}from 'react'
import "./Fast.less"
import {GetFastApi} from "@/request/api"
import Img from "@/static/images/home/subject.png"
import Button from '@mui/material/Button';
export default function Fast() {

  /* */
  
  /* */
  let [list,setlist] = useState<IRecords[]>([]);

  const Getfast = async()=>{
    let fastdata = sessionStorage.getItem("fastdata")
    if(fastdata){
      let data = JSON.parse(fastdata)
      console.log(data);
      setlist(data)
    }else{
      let res = await GetFastApi();
      if(res.errCode === 0){
        console.log(res);
        sessionStorage.setItem("fastdata",JSON.stringify(res.data.records))
      }
    }
  }

  useEffect(()=>{
    Getfast()
  },[])
  console.log(list);
  return (
    <div>
      {
        list.map((item,index)=>{
          return <div key={index} className="homeitem">
            <div className='left'><img src={Img} alt="" /></div>
            <div className='center'>{item.title}</div>
            <div className='right'><Button variant="contained" className="btn1">练习</Button></div>
          </div>
        })
      }
    </div>
  )
}
